package it.polimi.swKnights.SWIMv2.ejb.entityBeans;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.*;

/**
 * Entity implementation class for Entity: HelpRequest
 * 
 */
@Entity
@IdClass(HelpRequestPk.class)
public class HelpRequest implements Serializable
{
	@Id
	private long id;
	

	@Id
	@Column(name = "askingUserName", insertable = false, updatable = false)
	private String askingUserName;
	

	@Id
	@Column(name = "answeringUserName", insertable = false, updatable = false)
	private String answeringUserName;
	
	@ManyToOne
	@JoinColumn(name = "askingUserName", insertable = false, updatable = false)
	private RegisteredUser askingUser;


	@ManyToOne
	@JoinColumn(name = "answeringUserName", insertable = false, updatable = false)
	private RegisteredUser answeringUser;

	private String title;

	private String summary;

	//@Column(nullable = false) 
	private Date creationDate;

	private Date endDate;


	private boolean accepted;

	/*
	 * Serial Version ID
	 */
	
	private static final long serialVersionUID = 1L;

	/*
	 * Constructors
	 */
	
	public HelpRequest()
	{
		super();
	}

	public HelpRequest(long l, RegisteredUser askingUser,
			RegisteredUser answeringUser)
	{

		this.id = l;
		this.accepted = false;
		this.askingUserName = askingUser.getUserName();
		this.answeringUserName = answeringUser.getUserName();
		
	}
	
	/*
	 * Getters and setters
	 */
	public String getAskingUserName()
	{
		return this.askingUserName;
	}
	
	public String getAnsweringUserName()
	{
		return this.answeringUserName;
	}
	

	public String getTitle()
	{
		return title;
	}

	public void setTitle(String title)
	{
		this.title = title;
	}

	public String getSummary()
	{
		return summary;
	}

	public void setSummary(String summary)
	{
		this.summary = summary;
	}

	public Date getCreationDate()
	{
		return creationDate;
	}

	public void setCreationDate(Date creationDate)
	{
		this.creationDate = creationDate;
	}

	public String getId()
	{
	     Long i = this.id;
	     return i.toString();
	}
	
	public Date getEndDate()
	{
		return endDate;
	}

	public void setEndDate(Date endDate)
	{
		this.endDate = endDate;
	}

	public boolean getAccepted()
	{
		return this.accepted;
	}
	
	public void setAccepted(boolean accept) {
		
		this.accepted = accept;
	}

}
